#!/bin/sh
set -ev

# Directories.
root_dir=`pwd`
build_dir="/tmp/_travis/build"
install_dir="/tmp/_travis/install"

# Source ROS setup file
. "$root_dir/setup.sh"

# Create layout.
rm -rf "$build_dir" "$install_dir"
mkdir -p "$build_dir"
mkdir -p "$install_dir"

# Setup environment variables.
#export VREP_ROOT_DIR=/opt/vrep
#export LD_LIBRARY_PATH="$install_dir/lib:$LD_LIBRARY_PATH"
#export LD_LIBRARY_PATH="$install_dir/lib/`dpkg-architecture -qDEB_BUILD_MULTIARCH`:$LD_LIBRARY_PATH"
#export PKG_CONFIG_PATH="$install_dir/lib/pkgconfig:$PKG_CONFIG_PATH"
#export PKG_CONFIG_PATH="$install_dir/lib/`dpkg-architecture -qDEB_BUILD_MULTIARCH`/pkgconfig:$PKG_CONFIG_PATH"

cd "$root_dir"
catkin_init_workspace
cd "$build_dir"
cmake "$root_dir" -DCMAKE_INSTALL_PREFIX="$install_dir" -DVREP_ROOT_DIR=/opt/vrep
make
make install
make test
